import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

//异步按需加载
const Covdescribe=()=>import('../views/CovInfo/Covdescribe')
const Covtest = () => import('../page/daohangpage/Covtest')
const Riskarea = () => import('../page/daohangpage/Riskarea')
const Prevention = () => import('../page/daohangpage/Prevention')
const CitysInfo = () => import('../views/Citys/CitysInfo')
const Travel = () => import('../page/daohangpage/Travel')
Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'home',
        component: HomeView
    },
    {
        path: '/Covdescribe',
        name: 'Covdescribe',
        component: Covdescribe
    },
    {
        path: '/riskarea',
        name: 'area',
        component: Riskarea
    },
    {
        path: '/Covtest',
        name: 'covtest',
        component: Covtest
    },
    {
        path: '/Prevention',
        name: 'prevention',
        component: Prevention
    },
    {
        path: '/CitysInfo/:cityname/:indexs',
        name: 'citysInfo',
        component: CitysInfo,
        props: true
    },
    {
        path: '/Travel',
        name: 'travel',
        component: Travel,
    }

]

const router = new VueRouter({
    routes
})
// 页面跳转后页面的位置从最顶部开始
router.afterEach((to, from, next) => {
    window.scrollTo(0, 0);
});
export default router
